//
//  TitleBtn.swift
//  ZHFWB
//
//  Created by 张海峰 on 2017/2/27.
//  Copyright © 2017年 张海峰. All rights reserved.
//

import UIKit

class TitleBtn: UIButton {
    //MARK:- 重写init函数
     override init(frame: CGRect) {
        super.init(frame: frame)
        //中间的Btn
        setImage(UIImage.init(named:"下箭头"), for: .normal)
        setImage(UIImage.init(named:"上箭头"), for: .selected)
        setTitleColor(UIColor.black, for: .normal)
        sizeToFit()
    }
    //swift中规定： 重写控件的init（frame方法）或者init()方法，必须重写init?(coder aDecoder: NSCoder)
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override func layoutSubviews() {
        super.layoutSubviews()
        titleLabel!.frame.origin.x = 0
        imageView!.frame.origin.x = titleLabel!.frame.size.width + 5
    }
}
